import unittest
import os
import time

import HTMLTestRunner

report_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
html_report_filename = time.strftime('%Y%m%d%H%S%M') + 'HTMLReport.html'
html_report_path = os.path.join(report_path, 'report/', html_report_filename)
loader = unittest.defaultTestLoader.discover('../case', 'test*')
with open(html_report_path, 'wb') as f:
    runner = HTMLTestRunner.HTMLTestRunner(
        title='测试报告',
        description='测试报告描述',
        tester='王杰',
        stream=f,
        verbosity=2
    )
    runner.run(loader)
